package com.time.thread.threadLocal;

import static com.time.thread.threadLocal.ThreadLocalTest.localVar;
import static com.time.thread.threadLocal.ThreadLocalTest.print;

/**
 * @program: tes
 * @description: 没看懂
 * @author: xuejingjing
 * @create: 2021-10-22 14:23
 **/
public class ThreadLocalMain {
    public static void main(String[] args) {

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                //设置线程1中本地变量的值
                localVar.set("localVar1");
                //调用打印方法
                print("thread1");
                //打印本地变量
                System.out.println("after remove:"+localVar.get());
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                //设置线程1中本地变量的值
                localVar.set("localVar2");
                //调用打印方法
                print("thread2");
                //打印本地变量
                System.out.println("after remove:"+localVar.get());
            }
        });

        t1.start();
        t2.start();
    }
}
